package exercise.jslide.jslide.model.shapes;

import javafx.scene.canvas.GraphicsContext;
import javafx.geometry.Point2D;



public class Ellipse extends Shape {
    @Override
    protected void drawShape(GraphicsContext gc) {
        gc.fillOval(x, y, width, height);
        gc.strokeOval(x, y, width, height);

    }

    @Override
    public boolean contains(Point2D point) {
        double centerX = x + width/2;
        double centerY = y + height/2;
        double a = width/2;
        double b = height/2;

        return Math.pow((point.getX() - centerX)/a, 2) +
                Math.pow((point.getY() - centerY)/b, 2) <= 1;
    }

    @Override
    public Shape clone() {
        Ellipse clone = new Ellipse();
        clone.x = this.x;
        clone.y = this.y;
        clone.width = this.width;
        clone.height = this.height;
        clone.fillColor = this.fillColor;
        clone.strokeColor = this.strokeColor;
        clone.strokeWidth = this.strokeWidth;
        return clone;
    }
}
